﻿using System;
using System.Web.Services;
using BLL;
using BLL.RF.Package;
using Model;
using Model.RF.Package;

/// <summary>
///ProductPackage_LabelPrint_forNSN_Service 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class ProductPackage_LabelPrint_forNSN_Service : System.Web.Services.WebService
{
    PackageProduct pp;
    Pack_Label_Print print;

    public ProductPackage_LabelPrint_forNSN_Service()
    {
        pp = new PackageProduct();
        print = new Pack_Label_Print();
        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld()
    {
        return "Hello World";
    }

    [WebMethod(Description = "判断产品是否包装过")]
    public bool HasValid_PackageData(string packageProductSN)
    {
        return !string.IsNullOrEmpty(pp.GetPackageProductbyPackageProductSN(packageProductSN).ProductSN)
            && pp.GetPackageProductbyPackageProductSN(packageProductSN).IsPackage.Equals("Yes", StringComparison.OrdinalIgnoreCase);
    }

    [WebMethod(Description = "通过成品序列号，获取关联工序中的S代码，在HasValid_PackageData接口返回ture后调用")]
    public string GetProductTypeID_byPackageProductSN(string packageProductSN)
    {
        return pp.GetPackageProductbyPackageProductSN(packageProductSN).ProductTypeID;
    }

    [WebMethod(Description = "外箱标签打印记录数据上传，返回值为数据的上传是否成功")]
    public bool DataUpload(string packageProductSN, string userID,string pCIP)
    {
        Pack_Label_PrintInfo pi = new Pack_Label_PrintInfo() { ID = 0, PackageProductSN = packageProductSN, RecordTime = DateTime.Now, UserID = userID, PCIP = pCIP };
        return print.Insert(pi);
    }
}

